<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>qLibc: extensions/qconfig.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">qLibc
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('qconfig_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">qconfig.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>INI-style configuration file parser.  
<a href="#details">More...</a></p>

<p><a href="qconfig_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ab62078f483e0002c4cd7d8f993a674a1"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab62078f483e0002c4cd7d8f993a674a1"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>_INCLUDE_DIRECTIVE</b>&#160;&#160;&#160;&quot;@INCLUDE &quot;</td></tr>
<tr class="separator:ab62078f483e0002c4cd7d8f993a674a1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a935668a20d0b3f5b6b84b46e9262bc0b"><td class="memItemLeft" align="right" valign="top">qlisttbl_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qconfig_8c.html#a935668a20d0b3f5b6b84b46e9262bc0b">qconfig_parse_file</a> (qlisttbl_t *tbl, const char *filepath, char sepchar)</td></tr>
<tr class="memdesc:a935668a20d0b3f5b6b84b46e9262bc0b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Load &amp; parse configuration file.  <a href="#a935668a20d0b3f5b6b84b46e9262bc0b">More...</a><br/></td></tr>
<tr class="separator:a935668a20d0b3f5b6b84b46e9262bc0b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae70b6b473d2fcb3f17bde60297007336"><td class="memItemLeft" align="right" valign="top">qlisttbl_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qconfig_8c.html#ae70b6b473d2fcb3f17bde60297007336">qconfig_parse_str</a> (qlisttbl_t *tbl, const char *str, char sepchar)</td></tr>
<tr class="memdesc:ae70b6b473d2fcb3f17bde60297007336"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parse string.  <a href="#ae70b6b473d2fcb3f17bde60297007336">More...</a><br/></td></tr>
<tr class="separator:ae70b6b473d2fcb3f17bde60297007336"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>INI-style configuration file parser. </p>

<p>Definition in file <a class="el" href="qconfig_8c_source.html">qconfig.c</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a935668a20d0b3f5b6b84b46e9262bc0b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qlisttbl_t* qconfig_parse_file </td>
          <td>(</td>
          <td class="paramtype">qlisttbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>filepath</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&#160;</td>
          <td class="paramname"><em>sepchar</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Load &amp; parse configuration file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>a pointer of qlisttbl_t. NULL will generate a new table. </td></tr>
    <tr><td class="paramname">filepath</td><td>configuration file path </td></tr>
    <tr><td class="paramname">sepchar</td><td>separater used in configuration file to divice key and value</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of qlisttbl_t in case of successful, otherwise(file not found) returns NULL</dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor"># This is &quot;config.conf&quot; file.</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor"># A line which starts with # character is comment</span></div>
<div class="line"><span class="preprocessor"></span></div>
<div class="line">@INCLUDE config.def  =&gt; include <span class="stringliteral">&#39;config.def&#39;</span> file.</div>
<div class="line"></div>
<div class="line">prefix=/tmp        =&gt; set <span class="keyword">static</span> value. <span class="stringliteral">&#39;prefix&#39;</span> is the key <span class="keywordflow">for</span> <span class="keyword">this</span> entry.</div>
<div class="line">log=${prefix}/log  =&gt; <span class="keyword">get</span> the value from previously defined key <span class="stringliteral">&#39;prefix&#39;</span>.</div>
<div class="line">user=${%USER}      =&gt; <span class="keyword">get</span> environment variable.</div>
<div class="line">host=${!/bin/hostname -s}  =&gt; run external command and <a class="code" href="qhttpclient_8c.html#ae9ac3bd43c11509c0cbd8fb284bf13eb">put</a> it<span class="stringliteral">&#39;s output.</span></div>
<div class="line"><span class="stringliteral">id=${user}@${host}</span></div>
<div class="line"><span class="stringliteral"></span></div>
<div class="line"><span class="stringliteral"># now entering into &#39;</span>system<span class="stringliteral">&#39; section.</span></div>
<div class="line"><span class="stringliteral">[system]           =&gt; a key &#39;</span>system.<span class="stringliteral">&#39; with value &#39;</span>system<span class="stringliteral">&#39; will be inserted.</span></div>
<div class="line"><span class="stringliteral">ostype=${%OSTYPE}  =&gt; &#39;</span>system.ostype<span class="stringliteral">&#39; is the key for this entry.</span></div>
<div class="line"><span class="stringliteral">machtype=${%MACHTYPE}  =&gt; &#39;</span>system.machtype<span class="stringliteral">&#39; is the key for this entry.</span></div>
<div class="line"><span class="stringliteral"></span></div>
<div class="line"><span class="stringliteral"># entering into &#39;</span>daemon<span class="stringliteral">&#39; section.</span></div>
<div class="line"><span class="stringliteral">[daemon]</span></div>
<div class="line"><span class="stringliteral">port=1234</span></div>
<div class="line"><span class="stringliteral">name=${user}_${host}_${system.ostype}_${system.machtype}</span></div>
<div class="line"><span class="stringliteral"></span></div>
<div class="line"><span class="stringliteral"># escape section. (go back to root)</span></div>
<div class="line"><span class="stringliteral">[]</span></div>
<div class="line"><span class="stringliteral">rev=822</span></div>
</div><!-- fragment --><div class="fragment"><div class="line"><span class="preprocessor"># This is &quot;config.def&quot; file.</span></div>
<div class="line"><span class="preprocessor"></span>prefix = /usr/local</div>
<div class="line">bin = ${prefix}/bin</div>
<div class="line">log = ${prefix}/log</div>
<div class="line">user = unknown</div>
<div class="line">host = unknown</div>
</div><!-- fragment --><div class="fragment"><div class="line">qlisttbl_t *tbl = <a class="code" href="qconfig_8c.html#a935668a20d0b3f5b6b84b46e9262bc0b">qconfig_parse_file</a>(NULL, <span class="stringliteral">&quot;config.conf&quot;</span>, <span class="charliteral">&#39;=&#39;</span>, <span class="keyword">true</span>);</div>
<div class="line">tbl-&gt;debug(tbl, stdout);</div>
<div class="line"></div>
<div class="line">[Output]</div>
<div class="line">bin=/usr/local/bin? (15)</div>
<div class="line">prefix=/tmp? (5)</div>
<div class="line">log=/tmp/log? (9)</div>
<div class="line">user=seungyoung.kim? (9)</div>
<div class="line">host=eng22? (6)</div>
<div class="line"><span class="keywordtype">id</span>=seungyoung.kim@eng22? (15)</div>
<div class="line">system.=system? (7)</div>
<div class="line">system.ostype=linux? (6)</div>
<div class="line">system.machtype=x86_64? (7)</div>
<div class="line">daemon.=daemon? (7)</div>
<div class="line">daemon.port=1234? (5)</div>
<div class="line">daemon.name=seungyoung.kim_eng22_linux_x86_64? (28)</div>
<div class="line">rev=822? (4)</div>
</div><!-- fragment --> 
<p>Definition at line <a class="el" href="qconfig_8c_source.html#l00126">126</a> of file <a class="el" href="qconfig_8c_source.html">qconfig.c</a>.</p>

</div>
</div>
<a class="anchor" id="ae70b6b473d2fcb3f17bde60297007336"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qlisttbl_t* qconfig_parse_str </td>
          <td>(</td>
          <td class="paramtype">qlisttbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char&#160;</td>
          <td class="paramname"><em>sepchar</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Parse string. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>a pointer of qlisttbl_t. NULL will generate a new table. </td></tr>
    <tr><td class="paramname">str</td><td>key, value pair strings </td></tr>
    <tr><td class="paramname">sepchar</td><td>separater used in configuration file to divice key and value</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of qlisttbl_t in case of successful, otherwise(file not found) returns NULL</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="qconfig_8c.html#a935668a20d0b3f5b6b84b46e9262bc0b" title="Load &amp; parse configuration file. ">qconfig_parse_file</a></dd></dl>
<div class="fragment"><div class="line">qlisttbl_t *tbl;</div>
<div class="line">tbl = <a class="code" href="qconfig_8c.html#ae70b6b473d2fcb3f17bde60297007336">qconfig_parse_str</a>(NULL, <span class="stringliteral">&quot;key = value\nhello = world&quot;</span>, <span class="charliteral">&#39;=&#39;</span>);</div>
</div><!-- fragment --> 
<p>Definition at line <a class="el" href="qconfig_8c_source.html#l00216">216</a> of file <a class="el" href="qconfig_8c_source.html">qconfig.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_40c73bf2095fd0473b1b85ccdcac2768.html">extensions</a></li><li class="navelem"><a class="el" href="qconfig_8c.html">qconfig.c</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
